package com.uw.uwconfig.server.cluster;

import javax.sql.DataSource;

public class Cluster {

    private final DataSource dataSource;

    private ClusterMonitor clusterMonitor;
    private Election election;

    public Cluster(DataSource dataSource) {
        this.dataSource = dataSource;
    }



    public boolean status() {
        return election.getLock().get();
    }

    public void start() {
        election = new Election(dataSource);
        election.init();

        clusterMonitor = new ClusterMonitor(election);
        clusterMonitor.start();
    }


    public void stop() {
        clusterMonitor.stop();
        election.destroy();
    }


}
